<?php
namespace Admin\Controller;
use Think\Controller;
class WishManageController extends CommonController {
    public function index(){
        $sname=I('get.sname',"");
        $sop=I('get.sop',1);
        $wish=M("notes");
        $p=I('get.p',1);
        if($sop==1)
        {
        $wishda=$wish->where("name like '%$sname%'  ")->page($p.',10')->select();
        $count=$wish->where("name like '%$sname%'  ")->count();
        }
        else{
            $wishda=$wish->where("content like '%$sname%'  ")->page($p.',3')->select();
            $count=$wish->where("content like '%$sname%'  ")->count();
        }
            
        $PAGE=new \Think\Page($count,3);
        $PAGE->lastSuffix=false;
        $PAGE->setConfig('header', '共有%TOTAL_PAGE%页，当前是第%NOW_PAGE%页<br/>');
        $PAGE->setConfig('first', '首页');
        $PAGE->setConfig('last', '尾页');
        $PAGE->setConfig('prev', '上一页');
        $PAGE->setConfig('next', '下一页');
        $PAGE->setConfig('theme','%HEADER%   %FIRST%   %UP_PAGE%   %LINK_PAGE%   %DOWN_PAGE%   %END%');
        $show=$PAGE->show();
        $this->assign("wish",$wishda);
        $this->assign("sname",$sname);
        $this->assign("page",$show);
        $this->display ();   
    }
       public function del(){       
       $id=I('get.id',0);
	//实例化模型类
	$model=M('notes'); 	     
	$rs=$model->delete($id);
	if ($rs)
	   { //设置成功后跳转页面的地址，
          $this->success('删除成功', U('Admin/WishManage/index'));  
	   }
	   else
	   { //错误页面的默认跳转页面是返回前一页，通常不需要设置
         $this->error('删除失败');
	   }
    }
    public function muldel(){
        $idx=I('post.cboxdel');
        $idsstr=implode(",",$idx);
        $model=M('notes'); 	     
	$rs=$model->delete($idsstr);
	if ($rs)
	   { //设置成功后跳转页面的地址，
          $this->success('删除成功', U('Admin/WishManage/index'));  
	   }
	   else
	   { //错误页面的默认跳转页面是返回前一页，通常不需要设置
         $this->error('删除失败');
	   }
    }
}